package org.tarena.auto.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.tarena.auto.user.LubanUser;

@Configuration
//当前环境必须存在一个key luban.user.enable 值必须是true
@ConditionalOnProperty(prefix="luban",name="user.enable",havingValue = "true")
public class LubanUserConfiguration {
    @Bean
    //当前环境不存在LubanUser的时候 自动创建一个
    @ConditionalOnMissingBean(type = "org.tarena.auto.user.LubanUser")
    //不能给使用者添加障碍,必须用你创建的LubanUser
    public LubanUser lubanUser(){
        return new LubanUser();
    }
}
